package com.paipai.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.paipai.entity.Carts;
import com.paipai.service.CartsService;

@RestController
@RequestMapping("/cart")
public class CartController {

	@Autowired
	private CartsService cartsService;

	@RequestMapping("/addcarts")
	public String addcarts(@RequestBody Carts carts) {
		String str = cartsService.addcarts(carts);

		return str;

	}

	/**
	 * 加入收藏
	 * 
	 * @param carts
	 * @return
	 */
	@RequestMapping("/addstorage")
	public String addstorage(String proids) {
		String str = cartsService.addstorage(proids);

		return "ok";

	}

	/**
	 * 将storage转移到redis
	 * 
	 * @param carts
	 * @return
	 */
	@RequestMapping("/findcarts")
	public List<Carts> findcarts() {
		List<Carts> list = cartsService.findcarts();

		return list;

	}

	/**
	 * 将storage转移到redis
	 * 
	 * @param carts
	 * @return
	 */
	@RequestMapping("/deletecarts")
	public String deletecarts(Integer id) {
		Long flag = cartsService.deletecartss(id);

		return flag >= 1 ? "ok" : "no";

	}

}
